package com.EM1.www.servlet;

import com.EM1.www.dao.ConnectQuestion;
import com.EM1.www.po.Question;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.ArrayList;

@WebServlet("/SelectQuestion")
public class SelectQuestion extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        String index = request.getParameter("index");
        HttpSession session = request.getSession();
        ArrayList<Question> questions = (ArrayList<Question>) session.getAttribute("questions");
        Question question=questions.get(Integer.parseInt(index));
        request.setAttribute("question",question);
        session.setAttribute("id",question.getId());
        request.getRequestDispatcher("updatequestion.jsp").forward(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}
